package com.dkm.ec.product.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.product.domain.ProdTrack;
import com.dkm.ec.product.persistence.dao.ProdTrackQueryDao;
import com.dkm.ec.product.persistence.entity.ProdTrackPo;
import com.dkm.ec.product.repository.ProdTrackRepository;

/**
 * 对象功能:产品浏览足迹 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-31 13:36:54
 */
@Repository
public class ProdTrackRepositoryImpl extends AbstractRepository<String, ProdTrackPo,ProdTrack> implements ProdTrackRepository{
	  
	@Resource
	private  ProdTrackQueryDao prodTrackQueryDao;

	public ProdTrack newInstance() {
		ProdTrackPo po = new ProdTrackPo();
		ProdTrack prodTrack = SpringHelper.getBean(ProdTrack.class);
		prodTrack.setData(po);
		return prodTrack;
	}

	public ProdTrack newInstance(ProdTrackPo po) {
		ProdTrack prodTrack = SpringHelper.getBean(ProdTrack.class);
		prodTrack.setData(po);
		return prodTrack;
	} 
	
	@Override
	protected IQueryDao<String, ProdTrackPo> getQueryDao() {
		return prodTrackQueryDao;
	}

	@Override
	public List<ProdTrackPo> findByUser(String userId) {
		if(StringUtils.isEmpty(userId))return null;
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("whereSql", " create_by_='"+userId+"'");
		return prodTrackQueryDao.findAll(param);
	}
	
}
